;(function () {
  //模板插槽不仅可以声明一个占位的坑，也可以声明一个要提取的部分，我们来看一个例子：
  type ReverseName<Str extends string> = Str extends `${infer First} ${infer Last}` ? `${Capitalize<Last>} ${First}` : Str

  type ReversedTomHardy = ReverseName<'Tom hardy'> // "Hardy Tom"
  type ReversedLinbudu = ReverseName<'Budu Lin'> // "Lin Budu"

  //你可能会想到，如果传入的字符串字面量类型中有多个空格呢？这种情况下，模式匹配将只会匹配首个空格，即 "A B C" 会被匹配为 "A" 与 "B C" 这样的两个结构：
  type ReversedRes1 = ReverseName<'A B C'>
})()
declare function handler2<Str extends string>(arg: `Guess who is ${Str}`): Str

handler2('Guess who is ') // ""
handler2('Guess who is  ') // " "
// handler2(`Guess who was `) // Error
// handler2(``) // Error
